package com.tim.helper.project.history;

import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.util.Arrays;

/**
 * @author
 * @Title:
 * @Package
 * @date 2022/12/3 11:47
 * @Description:
 */
public class XiaoFeiXiaHelper {
    @Test
    public void genBaoFuReq() throws NoSuchFieldException {
    String str =
        "参数名\t类型\t必传\t备注\n"
            + "outNumber\tstring\t是\t商户单号\n"
            + "fromAddress\tstring\t是\t寄件人地址，此内容百度地图得到\n"
            + "fromAddressDetail\tstring\t是\t寄件人地址，详细地址\n"
            + "fromCoordinate\tstring\t是\t寄件人坐标，型如：\"{\\\"lng\\\":113.65,\\\"lat\\\":34.88}\"\n"
            + "fromMobile\tstring\t是\t寄件人电话\n"
            + "fromName\tstring\t是\t寄件人\n"
            + "toAddress\tstring\t是\t收件人地址，此内容百度地图得到\n"
            + "toAddressDetail\tstring\t是\t收件人地址，详细地址\n"
            + "toCoordinate\tstring\t是\t收件人坐标，型如：\"{\\\"lng\\\":113.65,\\\"lat\\\":34.88}\"\n"
            + "toMobile\tstring\t是\t收件人电话\n"
            + "toName\tstring\t是\t收件人\n"
            + "goodsName\tstring\t否\t物品名称\n"
            + "goodsNum\tint\t否\t物品数量\n"
            + "weight\tint\t否\t公斤\n"
            + "insuredSumPrice\tdouble\t否\t保价\n"
            + "collectionPrice\tdouble\t否\t代收款\n"
            + "payMode\tstring\t是\t付费对象 1 寄付、2 到付，\n"
            + "remark\tstring\t否\t备注";
        String template = "/**\n*%4$s\t%3$s\n*/\nprivate %2$s %1$s;\n\n";
        str = str.replaceAll("\t\n", "\t \n")
                .replaceAll("\t$", "\t ")
                .replaceAll("\tDate\t", "\tString\t")
                .replaceAll("\tstring\t", "\tString\t");
    Arrays.stream(str.split("\n"))
        .filter(StringUtils::isNotBlank)
        .skip(1)
        .forEach(
            e -> {
              String[] strs = e.split("\t");
              if (strs.length < 4) {
                System.out.println(strs[0]);
              }else{
                  System.out.println(String.format(template, strs));
              }
            });
    }


}
